package com.buka.controller;

import com.buka.pojo.CinemaHouse;
import com.buka.service.CinemaService;
import com.buka.utils.ResponseJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Date;

/**
 * 影院端
 */
@Controller
@ResponseBody
@RequestMapping("/cinema")
public class CinemaController {

    @Autowired
    private CinemaService cinemaService;

    /**
     * 影院端登录
     */
    @PostMapping("/login")
    public ResponseJson login(String username, String password, HttpSession httpSession) {
        return cinemaService.login(username, password, httpSession);
    }

    /**
     * 添加影厅
     */
    @PostMapping("/addHouse")
    public ResponseJson addHouse(CinemaHouse cinemaHouse, HttpSession httpSession) {
        return cinemaService.addHouse(cinemaHouse, httpSession);
    }

    /**
     * 影厅列表
     */
    @PostMapping("/getHouseList")
    public ResponseJson getHouseList(HttpSession httpSession) {
        return cinemaService.getHouseList(httpSession);
    }

    /**
     * 设置排片
     */
    @PostMapping("/addArrange")
    public ResponseJson addArrange(int movieId, int houseId, @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm") Date startTime, int money, HttpSession session) {
        return cinemaService.addArrange(movieId, houseId, startTime, money, session);
    }

    /**
     * 电影列表(能放映)
     */
    @PostMapping("/getMovieList")
    public ResponseJson getMovieList() {
        return cinemaService.getMovieList();
    }

}